# Maintainer: Maxime Gauduin <alucryd@archlinux.org>

pkgname=ffms2
pkgver=2.40
pkgrel=4
pkgdesc='A libav/ffmpeg based source library and Avisynth plugin for easy frame accurate access'
arch=(loong64 x86_64)
url=https://github.com/FFMS/ffms2
license=(GPL)
depends=(ffmpeg)
makedepends=(
  avisynthplus
  git
)
optdepends=(
  'avisynthplus: AviSynth plugin'
  'vapoursynth: VapourSynth plugin'
)
provides=(
  avisynth-plugin-ffms2
  libffms2.so
  vapoursynth-plugin-ffms2
)
_tag=55c2af57f1bdc587ca98d2e28d3d764c00b3e13a
source=(git+https://github.com/FFMS/ffms2.git#tag=${_tag})
sha256sums=(SKIP)

prepare() {
  cd ffms2
  git cherry-pick -n 586d87de3f896d0c4ff01b21f572375e11f9c3f1
  mkdir -p src/config
  autoreconf -fiv
}

pkgver() {
  cd ffms2
  git describe --tags
}

build() {
  cd ffms2
  export CXXFLAGS="$CXXFLAGS $(pkg-config --cflags avisynth) -fpermissive"
  ./configure \
    --prefix=/usr \
    --enable-avisynth \
    --enable-shared \
    --disable-static
  make
}

package() {
  make DESTDIR="${pkgdir}" -C ffms2 install
  for s in {avi,vapour}synth; do
    install -dm 755 "${pkgdir}"/usr/lib/$s
    ln -s ../libffms2.so "${pkgdir}"/usr/lib/$s/
  done
}

# vim: ts=2 sw=2 et:
